#include "app_buffer.h"
#include "log.h"
#include <string.h>

int main(int argc, char const *argv[])
{
    buffer_t *buffer = app_buffer_init(1024);

    // 1 创建一个字符串并写入缓冲区
    char *str = "hello world";

    app_buffer_write(buffer, str, (u_int8_t)strlen(str));

    char *str1 = "wupengwei";

    app_buffer_write(buffer, str1, (u_int8_t)strlen(str1));

    char buf[100];
    int read_len = app_buffer_read(buffer, buf, 100);
    log_info("read_len:%d,buf:%.*s", read_len,read_len, buf);

    char buf2[100];
    int read_len2 = app_buffer_read(buffer, buf2, 100);
    log_info("read_len:%d,buf:%.*s", read_len2,read_len2, buf2);

    app_buffer_destroy(buffer);

    return 0;
}
